// 检查 jdks.json 中是否有 Windows x86_64 的包
const fs = require('fs');
const path = require('path');

function checkWindowsPackages() {
  try {
    const jdksPath = path.join(__dirname, 'jdks.json');
    const data = fs.readFileSync(jdksPath, 'utf8');
    const jdksData = JSON.parse(data);

    console.log('检查 Windows x86_64 包...\n');

    let windowsX64Count = 0;
    const vendors = new Set();

    jdksData.jdks.forEach(jdk => {
      if (jdk.packages) {
        jdk.packages.forEach(pkg => {
          if (pkg.os === 'windows' && pkg.arch === 'x86_64') {
            windowsX64Count++;
            vendors.add(jdk.vendor);

            if (windowsX64Count <= 5) { // 只显示前5个
              console.log(`供应商: ${jdk.vendor}, 版本: ${jdk.jdk_version}`);
              console.log(`文件名: ${pkg.archive_file_name}`);
              console.log(`大小: ${(pkg.archive_size / 1024 / 1024).toFixed(2)} MB`);
              console.log('---');
            }
          }
        });
      }
    });

    console.log(`\n总共找到 ${windowsX64Count} 个 Windows x86_64 包`);
    console.log('供应商列表:', Array.from(vendors));

    // 检查是否有 Oracle JDK 21
    const oracleJdk21 = jdksData.jdks.find(jdk =>
      jdk.vendor === 'Oracle' &&
      jdk.jdk_version === '21' &&
      jdk.packages &&
      jdk.packages.some(pkg => pkg.os === 'windows' && pkg.arch === 'x86_64')
    );

    if (oracleJdk21) {
      console.log('\n找到 Oracle JDK 21 Windows x86_64 包！');
      const pkg = oracleJdk21.packages.find(p => p.os === 'windows' && p.arch === 'x86_64');
      console.log('详细信息:', {
        vendor: oracleJdk21.vendor,
        version: oracleJdk21.jdk_version,
        fileName: pkg.archive_file_name,
        size: (pkg.archive_size / 1024 / 1024).toFixed(2) + ' MB',
        url: pkg.url.substring(0, 100) + '...'
      });
    } else {
      console.log('\n未找到 Oracle JDK 21 Windows x86_64 包');
    }

  } catch (error) {
    console.error('检查失败:', error);
  }
}

checkWindowsPackages();
